package com.tengju.bff.interfaces.data.vo;

import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author chenhang
 * @Date 2020/12/25
 */
@Data
public class AchievementBonusDiffInfoVO {

    Long idCode;
    List<AchievementBonusMidDiffDetailVO> diffInfoVOList = new ArrayList<>();
    List<AchievementBonusDiffInfoVO> children = new ArrayList<>();


    public void add(AchievementBonusMidDetailVO detailVO,AchievementBonusMidDetailVO compareDetailVO) {
        if (detailVO != null) {
            this.idCode = detailVO.getIdCode();
        }
        diffInfoVOList.add(new AchievementBonusMidDiffDetailVO(detailVO,compareDetailVO));
    }



    public StringBuilder print(Integer depth) {
        StringBuilder sb = new StringBuilder();
        StringBuilder tabSb = new StringBuilder();
        for (int i = 0; i < depth; i++) {
            sb.append("\t");
            tabSb.append("\t");
        }
        sb.append("L" + depth).append(": ").append(idCode).append("\r\n");
        diffInfoVOList.forEach(v -> {
            sb.append(v.print(tabSb));
        });
        if (CollectionUtils.isEmpty(children)) {
            return sb;
        }
        for (AchievementBonusDiffInfoVO child : children) {
            StringBuilder childrenPrint = child.print(depth + 1);
            sb.append(childrenPrint);
        }
        return sb;
    }


    public void addChild(AchievementBonusDiffInfoVO childMidInfo) {
        children.add(childMidInfo);
    }
}
